package com.woniuxy.enjoylife.utils;

import com.woniuxy.enjoylife.enums.StateEnum;

import lombok.Data;
import org.springframework.stereotype.Component;

@Data
@Component
public class ResponseResult<T> {
	private int statusCode;		// 状态码：后台处理的结果
	private StateEnum state;	// 处理请求的结果
	private String message;		// 消息，提示用
	private T data;				// 返回的数据

	public ResponseResult success(){
		this.setState(StateEnum.SUCCESS);
		this.setStatusCode(200);
		this.setMessage("操作成功！");
		return this;
	}

	public ResponseResult error(){
		this.setState(StateEnum.ERROR);
		this.setStatusCode(500);
		this.setMessage("操作失败！");
		return this;
	}
}
